<?php
/**
 * 登录
 * User: adophper
 * Date: 2018/3/29
 * Time: 9:35
 */
$this->title = Yii::t('frontend', 'login');
?>
<div class="contBox" style="padding-top: 240px;">
    <div class="login_min">

        <div class="logo_large img">
            <a href="/"><img src="/static/frontend/image/logo_2.png" /></a>
        </div>
        <form action="<?=Yii::$app->urlManager->createUrl(['member/login'])?>" method="post">
        <div class="login_min_item flex f_relative">
            <i class="iconfont">&#xe614;</i><input type="text" name="username" id="username" value="<?=!empty($data['username'])?$data['username']:''?>" placeholder="用户名/手机/邮箱" autocomplete="off" />
        </div>
        <div class="login_min_item flex f_relative">
            <i class="iconfont">&#xe629;</i><input type="password" name="password" id="password" placeholder="密码" autocomplete="off"  />
        </div>
        <div class="login_min_item">
            <input type="hidden" value="<?php echo Yii::$app->request->csrfToken; ?>" name="_csrf" id="_csrf" >
            <input type="submit" class="btn btn-lg btn_red login-btn" value="立即登陆" >
<!--            <button class="btn btn-lg btn_red login-btn">立即登陆</button>-->
        </div>
        <div class="login_min_item">
            <div class="flex login_tab f_center">
                <label class="sel checked"></label>
                <span><i>记住我</i></span>
                <em>|</em>
                <a href="<?=Yii::$app->urlManager->createUrl(['member/forgot'])?>"><i>忘记密码</i></a>
                <em>|</em>
                <a href="<?=Yii::$app->urlManager->createUrl(['member/register'])?>"><i>免费注册</i></a>
            </div>
        </div>
        </form>
        <div class="login_min_item">
            <div class="flex f_center login_cho">
                快捷登陆
                <a href="#" class="flex f_center"><i class="iconfont">&#xe62f;</i></a>
                <a href="#" class="flex f_center"><i class="iconfont">&#xe619;</i></a>
                <a href="#" class="flex f_center"><i class="iconfont">&#xe611;</i></a>
            </div>
        </div>
    </div>
</div>
<script>
    $('.login-btn').click(function () {
        var username = $('#username').val();
        if(username.match(/<|"/ig)) {
            alert('用户名包含敏感字符');
            return false;
        }
        if (/(admin|manager|administrator|guest)/.test(username)) {
            alert('请输入合法的用户名');
            return false;
        }
        var password = $('#password').val();
        var _csrf = $('#_csrf').val();
        if(!(/^1\d{10}$/.test(username)) && !(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(username))){
            var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
            if (unlen < 3 || unlen > 15) {
                alert(unlen < 3 ? '用户名不得小于 3 个字符\n' : '用户名不得超过 15 个字符\n');
                return false;
            }
            /*alert("请输入正确的手机号或者邮箱");
            return false;*/
        }
        if(!password){
            alert("请填写密码");
            return false;
        }
    })

</script>